﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;

namespace _2QWebProxy
{
    public class Server
    {
        public Socket serverSocket;
        public int port;
        public static SortedList<string, CClient> clients;

        public Server()
        {
            serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            clients = new SortedList<string, CClient>();
        }

        public bool Listen()
        {
            try
            {
                serverSocket.Bind(new IPEndPoint(IPAddress.Any, port));
                serverSocket.Listen((int)SocketOptionName.MaxConnections);
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
